<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>ref的回调写法</title>
		<!-- 引入react核心库 -->
		<script type="text/javascript" src="../js/react.js"></script>
		<!-- 引入react-dom，用于支持react操作DOM -->
		<script type="text/javascript" src="../js/react-dom.js"></script>
		<!-- 引入babel，用于解析jsx为js -->
		<script type="text/javascript" src="../js/babel.min.js"></script>
	</head>
	<body>
		<!-- 准备好一个容器 -->
		<div id="root"></div>

		<script type="text/babel">
			//定义一个组件
			class Demo extends React.Component{
				render(){
					return (
						<div>
							<input ref={c => this.inpt1 = c} type="text" placeholder="点击按钮提示输入"/>	&nbsp;
							<button onClick={this.showMsg}>点我提示左侧数据</button>&nbsp;
							<input ref={c => this.inpt2 = c} type="text" onBlur={this.showMsg2} placeholder="失去焦点提示输入"/>	
						</div>
					)
				}
				showMsg = ()=>{
					console.log(this)
					alert(this.inpt1.value)
				}
				showMsg2 = ()=>{
					alert(this.inpt2.value)
				}
			}
			//渲染组件到页面
			ReactDOM.render(<Demo/>,document.getElementById('root'))
		</script>
	</body>
</html>